<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">

<section class="content-header">
    <h1>提报计划查询</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label for="query-proCode">项目编号</label>
                                    <input id="query-proCode" type="text" name="proCode" class="form-control"
                                           placeholder="请输入项目编号"  th:value="${proCode}">
                                </div>
                                <div class="form-group">
                                    <label for="query-proName">项目名称</label>
                                    <input id="query-proName" type="text" name="proName" class="form-control"
                                           placeholder="请输入项目名称">
                                </div>
                                <div class="form-group">
                                    <label for="query-reportType">分类</label>
                                    <select id="query-reportType" class="form-control" name="reportType">
                                        <option value="" th:selected="${reportType == null}">请选择</option>
                                        <option value="1" th:selected="${reportType == 1}">外购件</option>
                                        <option value="2" th:selected="${reportType == 2}">外协件</option>
                                        <option value="3" th:selected="${reportType == 3}">原材料</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query-malType">类型</label>
                                    <select id="query-malType" class="form-control" name="malType">
                                        <option value="" selected>请选择</option>
                                        <option th:each="type : ${malTypes}" th:value="${type.name}"
                                                th:text="${type.name}"></option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query-part">部分</label>
                                    <input id="query-part" type="text" name="part" class="form-control"
                                           placeholder="请输入部分">
                                </div>
                                <div class="form-group">
                                    <label for="query-sheetType">提报类型</label>
                                    <select id="query-sheetType" class="form-control" name="sheetType">
                                        <option value="" selected>请选择</option>
                                        <option value="1">提报单</option>
                                        <option value="2">变更单</option>
                                        <!--<option value="3">外协件计划单</option>-->
                                        <!--<option value="4">外协件计划变更单</option>-->
                                        <!--<option value="5">原材料计划单</option>-->
                                        <!--<option value="6">原材料计划变更单</option>-->
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query-status">提报状态</label>
                                    <select id="query-status" class="form-control" name="status">
                                        <option value="" selected>请选择</option>
                                        <option value="1">待提交</option>
                                        <option value="2">待科级审</option>
                                        <option value="3">待部级审</option>
                                        <option value="4">已提交</option>
                                    </select>
                                </div>
                                    <div shiro:hasPermission="report:query:other" class="form-group">
                                    <label for="query-dept">提报部门</label>
                                    <select id="query-dept" class="form-control" name="dept" style="width:150px;">
                                        <option value="">请选择</option>
                                        <option th:each="d : ${depts}" th:value="${d.id}"
                                                th:text="${d.name}"></option>
                                        <option value="-1">所有部门</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query-branchName">提报科室</label>
                                    <input id="query-branchName" type="text" name="branchName" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label for="query-postName">提报人</label>
                                    <input id="query-postName" type="text" name="postName" class="form-control">
                                </div>

                                <div class="form-group">
                                    <label for="query-startTime">日期</label>
                                    <input id="query-startTime" type="text" class="form-control datepicker" name="startTime"
                                           readonly="readonly"/>
                                    <label for="query-endTime"> 至 </label>
                                    <input id="query-endTime" type="text" class="form-control datepicker" name="endTime"
                                           readonly="readonly"/>
                                </div>
                                <button type="button" class="btn btn-success" id="btn-search"
                                        onclick="js.table.search(table)">
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    let table, typeName = ['', '外购件', '外协件', '原材料'], sheetType = ['','提报单','变更单'];

    $(function () {

        /** 加载列表 */
        table = js.table.init({
            url: ctx + "report/query/list",
            columns: [
                {
                    title: '序号', field: 'id', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: "分类", field: 'reportType',width: '60',
                    formatter: function (value) {
                        /*if (value === 1) {
                            return '<span class="badge label-success">外购件</span>';
                        } else if (value === 2) {
                            return '<span class="badge label-warning">外协件</span>';
                        } else if (value === 3) {
                            return '<span class="badge label-inverse">原材料</span>';
                        }*/
                        return typeName[value];
                    }
                },
                {title: "项目编号", field: 'proCode'},
                {title: "项目名称", field: 'proName',width:'250px'},
                {title: "项目数量", field: 'proNum'},
                {title: "类型", field: 'malType'},
                {title: "部分", field: 'part'},
                {title: "提报类型", field: 'sheetType',
                    formatter: function (value) {
                        /*if (value === 1) {
                            return '<span class="badge label-inverse">否</span>';
                        } else if (value === 2) {
                            return '<span class="badge label-success">是</span>';
                        }*/
                        return value === 1 ? '提报单' : '变更单';
                    }
                },
                {title: "提报人", field: 'postName'},
                {title: "提报科室", field: 'branchName'},
                {title: "提报状态", field: 'status',
                    formatter: function (value,row) {
                        /*if (value === 0) {
                            return '<span class="badge label-inverse">未审核</span>';
                        } else if (value === 1) {
                            return '<span class="badge label-success">已审核</span>';
                        }*/
                        // return value < 6 ? '<span class="badge label-inverse">未提交</span>' : '<span class="badge label-success">已提交</span>';
                        if (value === 1 || value === 3) {
                            return '<span class="badge label-inverse">待提交</span>';
                        } else if (value === 2 && row.reviewCur === 1) {
                            return '<span class="badge label-warning">待科级审</span>';
                        } else if (value === 2 && row.verifyCur === 1) {
                            return '<span class="badge label-warning">待部级审</span>';
                        } else {
                            return '<span class="badge label-success">已提交</span>';
                        }
                    }
                },
                {title: "提报日期", field: 'commitTime',width:'100px'},
                {title: "批准时间", field: 'verifyTime',width:'100px'},
                {title: "操作",
                    formatter: function (value, row) {
                        let actions = [];
                        actions.push('<a class="btn btn-info btn-xs" target="_blank" href="' + ctx + 'report/query/info/' + row.id + '"> 查看</a> ');
                        actions.push('<a class="btn btn-primary btn-xs" target="_blank" href="' + ctx + 'report/query/print/' + row.id + '"> 打印</a> ');
                        return actions.join('');
                    }
                }
            ]
        });


    });
</script>
</body>
</html>
